<?

		$sql['tables'][] = "INNER JOIN geograph_live.gridimage_group AS gg USING (gridimage_id)";

		
		
		$sql['order'] = "score desc, label, sort_order, ".$sql['order'];
		
		
		if (strpos($sql['columns'], ",label") === FALSE) {
			$sql['columns'] .= ",label";
		} 
		function searchbreak(&$c,$start='',$end='') {
			static $last;
			static $count;
			static $hidden;

			if (empty($c)) {//its the last one
				if ($last) {
					print $end;
					if ($hidden) {
						print "($hidden hidden images - <a href=\"".linktoself(array('cluster'=>$last,'delete'=>array('opt','page')))."\">view all</a>)";
					}
				}
				return;
			}
			
			$label = $c['label'];
			
			if ($label != $last) {
			
				if ($last) {
					print $end;
					if ($hidden) {
						print "($hidden hidden images - <a href=\"".linktoself(array('cluster'=>$last,'delete'=>array('opt','page')))."\">view all</a>)";
					} else {
						?>
						<script>
						if (document.getElementById('f<? echo $last; ?>')) {
							document.getElementById('f<? echo $last; ?>').style.display = 'none';
						}
						</script>
						<?
					}
				}
				
				print "<h4>".he($label);
					print " <span id=\"f$label\">(<a href=\"".linktoself(array('cluster'=>$label,'delete'=>array('opt','page')))."\">Show only</a>)</span>";
				print "</h4>";

				
					
				
				print $start;
				$count = 1;
				$hidden =0;
			} else {
				$count++;
				if ($count > 4) {
					$GLOBALS['opt']['has_hidden'] = true;
					$GLOBALS['resultCount']--;
					$hidden++;
					return false;
				}
			}
			
			$last = $label;
			return true; //we dont disable any images...
		}
		
		$opt['opt'] = 'cluster';
		$opt['title'] = "Images in cluster popularity order"; 

